﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace MefTZAddin.interop
{
    public static class SendMessageInterop
    {
        const int WM_SETTINGCHANGE = 0x1a;
        const int HWND_BROADCAST = (-1);
        const int SMTO_ABORTIFHUNG = 0x2;

        [DllImport("user32", EntryPoint = "SendMessageTimeoutA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        private static extern int SendMessageTimeout(int hwnd, int msg, int wParam, string lParam, int fuFlags, int uTimeout, ref int lpdwResult);

        public static int BroadcastSettingsChange()
        {
            int rtnValue = 0;
            return SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, "intl", SMTO_ABORTIFHUNG, 5000, ref rtnValue);
        }


    }
}
